<table>
  <tr valign="top">
    <td height="40" align="left" class="dato" background="/images/topHeader.gif" >Estadisticas varias para usuario <%= @userinfo.name %></td>
  </tr>
    <tr>
     <td align="center" background="/images/vg.jpg"><span class="subdatos">Información de apuestas de  usuario</span></td>
  </tr>
    <tr><td>&nbsp;</td></tr>

</table>



<table width="900" border="1">

<tr align = "center">
	<td><h2>Evento</h2></td>
	<td><h2>A quien apuesta</h2></td>
	<td><h2>Monto Apuesta</h2></td>
	<td><h2>Status Apuesta</h2></td>
	<td><h2>Proporcion Relativa</h2></td>
	<td><h2>Ganancia</h2></td>
</tr>

<% 
@totalbet = 0
@totalwin = 0

for bets in @bets 

@eventparticipant=Eventparticipant.find_by_id(bets.eventparticipant_idf)
@participant=Participant.find_by_id(@eventparticipant.participant_idf)
@event=Event.find_by_id(@eventparticipant.event_idf)
%>

<tr>
	<td><%= @event.name %></td>
	<td><%= @participant.name %></td>
	<td><%= bets.ammount %></td>
	
<%

@totalbet=@totalbet+bets.ammount

for participants in Eventparticipant.find_all_by_event_idf(@event.id)

%>

<% if participants.id != @eventparticipant.id %>
<%   if participants.score.nil? && @eventparticipant.score.nil?  %>

<td>Evento sin finalizar</td>
	<td><%= @eventparticipant.proportion%></td>
	<td>N/A</td>
</tr>

<%   else    %>

<% if participants.score > @eventparticipant.score %>
<td>Perdedor</td>
	<td><%= @eventparticipant.proportion%></td>
	<td>N/A</td>
</tr>
<% else %>
<td>Ganador</td>
	<td><%= @eventparticipant.proportion%></td>
	<td><%= bets.ammount*@eventparticipant.proportion %></td>
</tr>
<% @totalwin=@totalwin+bets.ammount*@eventparticipant.proportion %>

<% end
  end
 end
end

%>



<% 



end %>

</table>
    <tr><td>&nbsp;</td></tr>    <tr><td>&nbsp;</td></tr>
<table>
  <tr valign="top">
    <td height="40" align="left" class="dato" background="/images/topHeader.gif" >Estadisticas</td>
  </tr>
    <tr>
     <td align="center" background="/images/vg.jpg"><span class="subdatos">Informacion</span></td>
  </tr>
    <tr><td>&nbsp;</td></tr>

</table>


<table width="400" border="1">
  <tr>
  	<td>Total Apostado:</td>
  	<td><%= @totalbet %> </td>
  </tr>
  <tr>
  	<td>Total Ganado:</td>
  	<td><%= @totalwin %></td>
  </tr>
  <tr>
  	<td><h2>Ganancia de la casa</h2></td>
  	<td><h2><%= @totalbet-@totalwin %></h2></td>
  </tr>
  </table>
<table>